﻿using System.Reflection;
using Abp.AutoMapper;
using Abp.Modules;
using Abp.Reflection.Extensions;
using MyBlog.Admin.Authorization;
using Abp.Runtime.Caching.Redis;

namespace MyBlog.Admin
{
    [DependsOn(
        typeof(AdminCoreModule), 
        typeof(AbpAutoMapperModule),
        typeof(AbpRedisCacheModule))]
    public class AdminApplicationModule : AbpModule
    {
        public override void PreInitialize()
        {
            Configuration.Authorization.Providers.Add<AdminAuthorizationProvider>();

            //注入redis
            Configuration.Caching.UseRedis();
        }

        public override void Initialize()
        {
            Assembly thisAssembly = typeof(AdminApplicationModule).GetAssembly();
            IocManager.RegisterAssemblyByConvention(thisAssembly);

            Configuration.Modules.AbpAutoMapper().Configurators.Add(cfg =>
            {
                //Scan the assembly for classes which inherit from AutoMapper.Profile
                cfg.AddProfiles(thisAssembly);
            });
        }
    }
}